const App = {
    mixins: [Save],//配置文件，路径/utils/mixins.js
    data() {
        return {
            category: [],
            village: [],
            member: [],
            person: [],
            city1: [],
            qwer: [],
            childDataForm1: [{}],
            is: true,

        };
    },
    mounted() {
        // let ls_URL = window.location.href;
        // let Party_Organization_Activity_SerialNumber = getQueryObject(ls_URL, "Party_Organization_Activity_SerialNumber");// 获取 nodeKey 参数
        // if (Party_Organization_Activity_SerialNumber) {
        //     this.dataForm.Party_Organization_Activity_SerialNumber = Party_Organization_Activity_SerialNumber;
        // }
        this.getVillage();

        $.ajax({
            //url: `${mh}/generalBusiness/getDistrictGridTree`,
            headers: requestHeaders(),
            url: `${mh}/clientOperation/getDistrictTree`,
            type: "GET",
            data: {
                DistrictCode: "232723"
            },
            success: (data) => {
                this.city1 = data[0].children;
            },
            complete: (XMLHttpRequest) => {
                requestPretreatment(XMLHttpRequest);
              },
            dataType: "json",
        });


    },
    watch: {
        'dataForm.Village_Number'(val) {
            if (this.action == 'Modify' && this.is) {
                this.is = false;
                let str = this.dataForm.Village_Number
                console.log(this.dataForm);
                $.ajax({
                    headers: requestHeaders(),
                    url: `${mh}/clientOperation/getDistrictTree`,
                    type: "GET",
                    data: {
                        DistrictCode: str.substring(0, 6)
                    },
                    success: (data) => {


                        this.qwer = [str.substring(0, 9), str];

                        // this.cityValue1 = [str.substring(0, 9), str];
                        // this.cityValue = [str.substring(0, 2) + '0000', str.substring(0, 4) + '00', str.substring(0, 6)]
                    },
                    complete: (XMLHttpRequest) => {
                        requestPretreatment(XMLHttpRequest);
                      },
                    dataType: "json",
                });
                
                $.ajax({
                    headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: "POST",
                data: {
                    Data: 'personal_information',
                    Condition: "Row_Status='0' AND RR_Village_Number='" + str + "'"
                },
                success: (data) => {
                    this.member = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                  },
                dataType: "json",
            });
                
            }
        },
    },
    methods: {
        

        changeVillage(val) {
            let _this = this;
            let str = val[val.length - 1];
            this.dataForm.Village_Number = str;
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: "POST",
                data: {
                    Data: 'personal_information',
                    Condition: "Row_Status='0' AND RR_Village_Number='" + str + "'"
                },
                success: (data) => {
                    this.member = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                  },
                dataType: "json",
            });
            
            _this.dataForm.Captain_Number = '';
            _this.dataForm.Mobile = '';
        },
        changeMember(val) {
            let _this = this;
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: "POST",
                data: {
                    Data: 'personal_information',
                    Condition: "Row_Status='0' AND ID_Card_Number='" + val + "'"
                },
                success: (data) => {
                    // this.person = data; // 直接使用 this
                    _this.dataForm.Mobile = data[0]["Contact_Phone"]
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                  },
                dataType: "json",
            });

        },
        getVillage() {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: "POST",
                data: {
                    Data: 'base_system_village',
                    Condition: "TownNumber LIKE '232723%'",
                },
                success: (data) => {
                    this.village = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });

            //     $.ajax({
            //     url: `${mh}/clientOperation/getDistrictTree`,
            //     type: "GET",
            //     data: {
            //       DistrictCode: '232723'

            //     },
            //     success: (data) => {
            //       this.village = data; // 直接使用 this
            //     },
            //     dataType: "json",
            //   });
        },

    },
};
const { createApp, ref } = Vue;
const app = createApp(App);
app.use(ElementPlus, { locale: zhCn });
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
app.component('yl-upload', ylUpload);
app.component('yl-text-editor', ylTextEditor);
const ElMessage = ElementPlus.ElMessage;
app.mount("#app");
